#include <iostream>
#include <cstdio>
#define MAXN 1010

int n;
int a[MAXN],f[MAXN];

void pozhi()
{
    for (int i=0 ;i< n;i++)
        f[i]=1;
    for (int j=1;j<n;j++)
        for (int k= 0;k<j;k++)
        {
            if (a[k]>a[j])
                f[j]=f[k]+1>f[j]?f[k]+1:f[j];
        }
    int max=0;
    for (int i=0;i<n;i++)
    {
        if (f[i]>max)
            max=f[i];
    }
    printf("%d",max);
}

int main ()
{
    //freopen("a.in","r",stdin);
    //freopen("b.out","w",stdout);
    scanf("%d",&n);
    for (int i = 0 ;i < n;i++ )
        scanf("%d",&a[i]);
    pozhi();
    return 0;
}
